import { defHttp } from '/@/common/util/axios';

enum Api {
  getBaseRelList = '/emp/common/getBaseRelList', // 人员下拉框options
  getMonitoringStatus = '/emp/hubTeamMonitoring/getMonitoringStatus',  //监控转态：查询是否可编辑修改
  getPersonTypeListByType = '/emp/pnelCommon/getPersonTypeList',
  getPeriodTree = '/emp/epmBasePeriod/periodTree', //考核周期树
  getSuitUnitOrgApi = '/emp/common/findTree', // 上级部门树
}

export const getPeriodByParams = (params) => defHttp.post({ url: Api.getPeriodTree, params });
/**
 * 获取周期树
 * @param params
 */
export const getPeriodTree = () => {
  const params = {
    type: 'yearM',
  };
  return new Promise((resolve) => {
    defHttp.post({ url: Api.getPeriodTree, params }, { joinParamsToUrl: true }).then((res) => {
      res.forEach((item) => {
        item.disabled = true;
      });
      resolve(res);
    });
  });
};

export const getPeriodTreeAll = () => {
  const params = {
    type: 'yearM',
  };
  return new Promise((resolve) => {
    defHttp.post({ url: Api.getPeriodTree, params }, { joinParamsToUrl: true }).then((res) => {
      resolve(res);
    });
  });
};

export const getPeriodTreeByYear = () => {
  const params = {
    type: 'year',
  };
  return new Promise((resolve) => {
    defHttp.post({ url: Api.getPeriodTree, params }, { joinParamsToUrl: true }).then((res) => {
      resolve(res);
    });
  });
};
export const getPeriodTreeByQuarter = () => {
  const params = {
    type: 'yearQuarter',
  };
  return new Promise((resolve) => {
    defHttp.post({ url: Api.getPeriodTree, params }, { joinParamsToUrl: true }).then((res) => {
      res.forEach((item) => {
        item.disabled = true;
      });
      resolve(res);
    });
  });
};

export const getBaseRelList = (params) => defHttp.get({ url: Api.getBaseRelList, params });
export const getMonitoringStatus = (params) => defHttp.post({ url: Api.getMonitoringStatus, params }, { isTransformResponse: false });
export const getPersonTypeListByType = () => defHttp.get({ url: Api.getPersonTypeListByType });
export const getSuitUnitOrg = () => defHttp.get({ url: Api.getSuitUnitOrgApi });